﻿namespace Leetcode.N0796;
public class Solution
{
    public bool RotateString(string s, string goal)
    {
        if (s.Length != goal.Length)
        {
            return false;
        }
        for (var i = 0; i < s.Length; i++)
        {
            if (this.Compare(s, i, goal))
            {
                return true;
            }
        }
        return false;
    }

    private bool Compare(string s, int index, string goal)
    {
        for (var i = index; i < s.Length; i++)
        {
            if (s[i] != goal[i - index])
            {
                return false;
            }
        }

        for (var i = 0; i < index; i++)
        {
            if (s[i] != goal[s.Length - index + i])
            {
                return false;
            }
        }
        return true;
    }
}
